package net.moonbiter.ebs;

import net.moonbiter.ebs.descriptors.Descriptor;

public class InputDef {
	private boolean optional;
	private Class<?> type;
	private Descriptor<?,?> specificDescriptor; 
	
	public InputDef(Class<?> typeValue, boolean optionalValue){
		optional = optionalValue;
		type = typeValue;
	}
	
	public InputDef(Class<?> typeValue, boolean optionalValue, Descriptor<?,?> specificDescriptor){
		this(typeValue,optionalValue);
		this.specificDescriptor = specificDescriptor;
	}
	
	public boolean hasSpecificDescriptor(){
		return null!=specificDescriptor;
	}
	
	public Descriptor<?,?> getSpecificDescriptor(){
		if (!hasSpecificDescriptor()){
			throw new IllegalStateException();			
		}
		return specificDescriptor;
	}
	
	public boolean isOptional() {
		return optional;
	}

	public Class<?> getType() {
		return type;
	}

	@Override
	public String toString() {
		return getType().getCanonicalName()+", optional? "+isOptional();
	}
	
}
